﻿using PLCSimulator.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PLCSimulator.Views
{
    /// <summary>
    /// EditorDiagramVIew.xaml 的交互逻辑
    /// </summary>
    public partial class EditorDiagramView : UserControl
    {
        public EditorDiagramView()
        {
            InitializeComponent();
        }

        public EditorDiagramViewModel ViewModel { get; set; } = new EditorDiagramViewModel();

        public void Add(FrameworkElement element, Point pointF)
        {
            var pos = Symbol.ScreenPoint(new Point(pointF.X / ViewModel.ScaleXY, pointF.Y / ViewModel.ScaleXY));
            Canvas.SetLeft(element, pos.X);
            Canvas.SetTop(element, pos.Y);
            this.Diagram.Children.Add(element);
        }
    }
}
